import mammoth from 'mammoth'

export function getWordText(name) {
  return new Promise((resolve, reject) => {
    const docxName = name
    console.log(docxName)
    const xhr = new XMLHttpRequest()
    xhr.open('get', `docx/${docxName}`, true)
    xhr.responseType = 'arraybuffer'
    xhr.onload = () => {
      if (xhr.status == 200) {
        mammoth.convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) }).then(resultObject => {
          resolve(resultObject.value)
        })
      }
    }
    xhr.send()
  })

}